package com.CNMedical.web.controller.system;

import java.util.List;

import com.CNMedical.system.domain.DTO.AppletKnowledgeCommentDTO;
import com.CNMedical.system.domain.vo.AppletKnowledgeCommentVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.CNMedical.common.annotation.Log;
import com.CNMedical.common.core.controller.BaseController;
import com.CNMedical.common.core.domain.AjaxResult;
import com.CNMedical.common.enums.BusinessType;
import com.CNMedical.system.domain.entity.AppletKnowledgeComment;
import com.CNMedical.system.service.IAppletKnowledgeCommentService;
import com.CNMedical.common.core.page.TableDataInfo;

/**
 * 知识留言Controller
 * 
 * @author tang
 * @date 2023-03-29
 */
@RestController
@RequestMapping("/system/knowledgeComment")
public class AppletKnowledgeCommentController extends BaseController
{
    @Autowired
    private IAppletKnowledgeCommentService appletKnowledgeCommentService;

    /**
     * 查询知识留言列表
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeComment:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletKnowledgeCommentDTO appletKnowledgeComment)
    {
        startPage();
        List<AppletKnowledgeCommentVO> list = appletKnowledgeCommentService.selectAppletKnowledgeCommentList(appletKnowledgeComment);
        return getDataTable(list);
    }

    /**
     * 获取知识留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeComment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletKnowledgeCommentService.selectAppletKnowledgeCommentById(id));
    }

    /**
     * 新增知识留言
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeComment:add')")
    @Log(title = "知识留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletKnowledgeComment appletKnowledgeComment)
    {
        return toAjax(appletKnowledgeCommentService.insertAppletKnowledgeComment(appletKnowledgeComment));
    }

    /**
     * 修改知识留言
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeComment:edit')")
    @Log(title = "知识留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletKnowledgeComment appletKnowledgeComment)
    {
        return toAjax(appletKnowledgeCommentService.updateAppletKnowledgeComment(appletKnowledgeComment));
    }

    /**
     * 删除知识留言
     */
    @PreAuthorize("@ss.hasPermi('system:knowledgeComment:remove')")
    @Log(title = "知识留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletKnowledgeCommentService.deleteAppletKnowledgeCommentByIds(ids));
    }
}
